<?php
include ("conectar.php"); //Conecta com a nosso banco de dados MySQL
include ("ver_sessao.php");  //Verifica se a sessão está ativa

if (isset($_SESSION['dados'])) {
	$dados = $_SESSION['dados'];
}
if (($dados['login_user'])==(admin)){
$usrSQL = mysql_query("SELECT * FROM tb_admin");
}

else {
$login_user=$dados['login_user'];
$usrSQL = mysql_query("SELECT * FROM tb_admin WHERE login_user='$login_user'");
//$usrSQL = mysql_query("SELECT id_user,date_format(inclusao_user,'%d/%m/%Y - %H:%i') as inclusao_user, nome_user,cidade_user,estado_user FROM tb_admin WHERE nome_user='$nome_user'");
}

//$usuarioSQL = mysql_query("SELECT * FROM tb_login");
/*Data*/
$data = date('d/m/y');
	$hora = date('H');
	$minute = date('i');
	$hour=($hora - 1);
	$day = date('d');
	$month= date('m');
	$year= (2000 + date('y'));
	
	/**********************************************************/
	switch ($month) {
    case 1:
        $mes = Jan;
        break;
    case 2:
        $mes = Fev;
        break;
	case 3:
        $mes = Mar;
        break;
	case 4:
        $mes = Abr;
        break;
	case 5:
        $mes = Mai;
        break;
	case 6:
        $mes = Jun;
        break;
	case 7:
        $mes = Jul;
        break;
	case 8:
        $mes = Ago;
        break;
    case 9:
        $mes = Set;
        break;
	case 10:
        $mes = Out;
        break;
	case 11:
        $mes = Nov;
        break;
	case 12:
        $mes = Dez;
        break;
	}
?>
<?
$id_usr = $_GET[id_usuario];
//echo $id_usr;
if (isset($_SESSION['dados'])) {
	$dados = $_SESSION['dados'];
		if ($id_usr==1){
		echo '<p align="center">O usuário Admin não pode ser excluído!<BR><a href="javascript:history.back(1);">Voltar</a></p>';
		}
		else{
		$sql_del = mysql_query("DELETE FROM tb_admin WHERE id_user='$id_usr'") or die("Erro no SQL: ".mysql_error());
		$atualizaSQL=mysql_query("ALTER TABLE tb_admin AUTO_INCREMENT = 1;");
		echo "<br><br><div align=center><font face=Arial size=2>Usuário EXCLUÍDO com Sucesso!
		<br><br><a href='home.php'>[ Voltar para à página Administrativa]</a> </font></div><br>";
		}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin.conta.dwt" codeOutsideHTMLIsLocked="false" -->
<head>

<title>.:: Expert3d - <?php echo ($dados['login_user']); ?>::.</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
function clearText(field) {
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<div id="header">
  <div id="site_title"> <a href="#">Soluções Tecnológicas</a> </div>
  <div id="header_right"> <a href="#"><img src="images/twitter.png" alt="" /></a><a href="#"><img src="images/rss.png" alt="" /></a>
    <div id="newsletter_box">
      <form action="#" method="get">
        <input type="text" id="user" name="user" class="newsletter_email" value="Enter your email address"  onfocus="clearText(this)" onblur="clearText(this)" />
        <input style="font-weight: bold;" type="submit" name="submit" id="submit" value="" />
      </form>
    </div>
  </div>
  <div class="cleaner"></div>
</div>
<!-- end of header -->
<div id="menu_wrapper">
  <div id="menu">
    <ul>
      <li><a href="home.php" class="current"><span></span>Home</a></li>
      <li><a href="#"><span></span>Web 2.0</a></li>
      <li><a href="#"><span></span>CSS Templates</a></li>
      <li><a href="#"><span></span>Graphics</a></li>
      <li><a href="#"><span></span>Inspirations</a></li>
      <li><a href="conta.php"><span></span>Minha Conta </a></li>
	  <li><a href="sair.php"><span></span>Sair </a></li>
    </ul>
  </div>
</div>
<!-- end of menu -->
<div id="main"> <span class="tm_bottom"></span>
  <div id="content"><!-- InstanceBeginEditable name="EditRegion1" -->
    <div class="post_box">
      <div class="header">
        <h2><a href="#">Excluir administradores </a></h2>
        <div class="tag"><strong>Tags:</strong> <a href="#">Photography</a>, <a href="#">Free Photos</a>, <a href="#">HDR</a></div>
        <span class="posted_date"> <?php echo $day ?> <?php echo $mes ?> <strong><?php echo $year ?></strong> </span> </div>
      <div class="table">
        <p>
		<?php if(mysql_num_rows($usrSQL) > 0) {?>
		<table width="100%" border="0" cellspacing="1">
            <tr bgcolor="#6699CC">
              <td colspan="4" bgcolor="#263441"><div align="center" class="style1">Informações dos Administradores </div></td>
            </tr>
            <tr bgcolor="cccccc" align="center">
              <td width="10%"><b><font face="Arial" size="2">Data de inclus&atilde;o</font></b></td>
			  <td width="14%"><span style="font-weight: bold"><font size="2" face="Arial">Login</font></span></td>
              <td width="14%"><span style="font-weight: bold"><font size="2" face="Arial">Nome</font></span></td>
			  <td width="13%"><strong><font size="2" face="Arial">Excluir</font></strong></td>
            </tr>
			<?php while($array_user = mysql_fetch_array($usrSQL))
	{?>
            <tr bgcolor="ebebeb" align="center">
              <td><?php echo $array_user['inclusao_user'];?></td>
			  <td><?php echo $array_user['login_user'];?></td>
              <td>
			  <?php
			  $array_user['nome_user'];
			  /*Função para mostrar só o primeiro nome do usuário*/
    		//Variavel aux fazendo o explode separando pelo caracter ' '
			  $aux = explode(' ',$array_user['nome_user']);
			  //Exibe o primeiro nome da string
    		  echo " ".$aux[0]."\n";
			  ?>
			  </td>
			  <td><div>[<a href='excluirusuario.php?id_usuario=<?php echo $array_user['id_user'];?>&amp;acao=entrar'>Excluir</a>]</a></div></td>
            </tr>
			<?php }?>
          </table>
		  <?php }/* fecha mysql_num_rows > 0 */
else{
echo "<br><br><div align=center><font face=Arial size=2> Não há usuários cadastrados como Administradores do banco!<br><br></font></div>";}?>		  </td>
                          </tr>
                      </table>
		</p>
        <p>&nbsp;</p>
      </div>
      <div class="cleaner"></div>
    </div>
  <!-- InstanceEndEditable -->
    <div class="post_box pb_last">
      <div class="cleaner"></div>
    </div>
  </div>
  <div id="sidebar">
    <div class="sidebar_box">
      <h3>Informações</h3>
      <div class="sb_content">
        <ul class="sidebar_menu">
		  <?php if (($dados['login_user'])==(admin)){ ?> <li><a href="cadadmin.php">Cadastrar</a></li>
		  <?php } ?>
          <li><a href="altuser.php">Alterar dados </a></li>
          <li><a href="trocarphoto.php">Alterar foto</a></li>
          <li><a href="#">Free Fonts</a></li>
          <li><a href="#">Photoshop Tutorials</a></li>
          <li><a href="#">3D Animation Tutorials</a></li>
		  <li><a href="trocarsenha.php">Trocar senha</a></li>
		  <li><a href="excluir.php">Excluir conta </a></li>
        </ul>
      </div>
    </div>
    <div class="sidebar_box">
      <h3>Archives</h3>
      <div class="sb_content">
        <ul class="sidebar_menu">
          <li><a href="#">CSS Templates</a></li>
          <li><a href="#">Web Design Ideas</a></li>
          <li><a href="#">Free Wallpapers</a></li>
          <li><a href="#">Free Pixel Fonts</a></li>
          <li><a href="#">Illustrator Tutorials</a></li>
          <li><a href="#">3D Character Tutorials</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="cleaner"></div>
</div>
<!-- end of main -->
<div id="bottom">
  <div class="bottom_box">
    <h5><span>Sed Necest</span> Suspendisse a nibh</h5>
    <p>Duis vitae velit sed dui malesuada dignissim. Donec mollis aliquet ligula. Maecenas adipiscing elementum ipsum.</p>
    <a href="#" class="continue">more info</a> </div>
  <div class="bottom_box">
    <h5><span>Lorem ipsum</span> dolor sit amet</h5>
    <p>Vestibulum eleifend, enim ut molestie pulvinar, purus est fringilla augue, ut tristique nunc neque a libero.</p>
    <a href="#" class="continue">more info</a> </div>
  <div class="bottom_box">
    <h5><span>Recent</span> Blog Post</h5>
    <ul class="bottom_box_list">
      <li><a href="#">Duis vitae velit sed lesuada dignissim.</a></li>
      <li><a href="#">Donec mollis aliquet ligula.</a></li>
      <li><a href="#">Maecenas adipiscing elementum ipsum.</a></li>
    </ul>
  </div>
</div>
<!-- end of bottom -->
<div id="footer">
  <ul class="footer_menu">
    <li class="first"><a href="#">Home</a></li>
    <li><a href="#">Web 2.0</a></li>
    <li><a href="#">Wordpress</a></li>
    <li><a href="#">Graphics</a></li>
    <li><a href="#">Inspirations</a></li>
    <li><a href="#">Freebies</a></li>
  </ul>
  Copyright &copy; 2012 <a href="home.php">Expert3d</a> | Designed by igor.giovanni@gmail.com</div>
</body>
<!-- InstanceEnd --></html>
